package models

import (
	"book/conf"
	"fmt"
	"github.com/go-redis/redis"
)

var Rdb *redis.Client

func RedisInit() {
	appConfig := conf.Conf.RedisConfig
	Rdb = redis.NewClient(&redis.Options{
		Addr:     appConfig.Addr,
		Password: appConfig.Passwor,
		DB:       appConfig.Db,
	})
	_, err := Rdb.Ping().Result()
	if err != nil {
		fmt.Println("redis数据连接失败")
		return
	}
	fmt.Println("redis数据连接成功")
}
